import request from '@/utils/request'

export default {
  getMovieAll() {
    return request({
      url: '/movie/all',
      method: 'get'
    })
  },
  getMovieList(searchModel) {
    return request({
      url: '/movie/list',
      method: 'get',
      params: {
        pageNo: searchModel.pageNo,
        pageSize: searchModel.pageSize,
        name: searchModel.name,
        cid: searchModel.cid
      }
    })
  },
  addMovie(movie) {
    return request({
      url: '/movie',
      method: 'post',
      data: movie
    })
  },
  getMovieById(id) {
    return request({
      // url:'/user/'+id,
      url: `/movie/${id}`,
      method: 'get'

    })
  },
  getMovie(id, is) {
    return request({
      // url:'/user/'+id,
      url: `/movie/${id}/${is}`,
      method: 'get'
    })
  },
  updateMovie(movie) {
    return request({
      url: '/movie',
      method: 'put',
      data: movie
    })
  },
  saveMovie(movie) {
    if (movie.id == null && movie.id === undefined) {
      return this.addMovie(movie)
    }
    return this.updateMovie(movie)
  },
  deleteMovieById(id) {
    return request({
      url: `/movie/${id}`,
      method: 'delete'
    })
  },

  upload(url, file) {
    return request({
      url: url,
      method: 'post',
      data: file
    })
  }
}
